/*
 * Copyright (c) 2021. Moses All Right Reserved
 */

package com.moses.design_patterns.observer;

/**
 * @author Moses
 * @email shenhuohui@gmail.com
 * @date 2021/4/17 16:56
 */
public class Client {
    public static void main(String[] args) {

        // 两个观察者
        Observer observer1 = new Observer1();
        Observer observer2 = new Observer2();

        // 两个被观察者
        Observee1 observee = new Observee1();
        Observee2 observee2 = new Observee2();

        // 被两个观察者观察
        observee.addObserver(observer1);
        observee.addObserver(observer2);

        // 一个观察者观察两个
        observee2.addObserver(observer1);

        observee.doSomething();
        System.out.println("==========");
        observee2.doSomething();
    }
}
